package qlsl.androiddesign.adapter.subadapter;

import java.util.List;

import com.qlsl.androiddesign.kuaiwa.R;

import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import qlsl.androiddesign.activity.baseactivity.BaseActivity;
import qlsl.androiddesign.adapter.baseadapter.BaseAdapter;
import qlsl.androiddesign.entity.otherentity.RecruitJob;
import qlsl.androiddesign.util.commonutil.ImageUtils;
import qlsl.androiddesign.util.commonutil.TimeFormatUtils;

public class JobRecruitAdapter<T> extends BaseAdapter<RecruitJob> {

	private String city;

	public void setCity(String city) {
		this.city = city;
	}

	public JobRecruitAdapter(BaseActivity activity, List<RecruitJob> list) {
		super(activity, list);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = getItemView(convertView, R.layout.listitem_job);

		TextView tv_text = getView(convertView,
				R.id.recruit_fragment_list_title);// 标题
		TextView tv_data = getView(convertView, R.id.recruit_fragment_list_time);// 2015-09-11
		TextView tv_recruit_job = getView(convertView,
				R.id.vehicle_fragment_item_text_time);// [武汉>招聘]
		TextView tv_content = getView(convertView,
				R.id.vehicle_fragment_item_text_context);// 内容

		ImageView tv_image = getView(convertView,
				R.id.recruit_fragment_list_img);

		RecruitJob recruitJob = getItem(position);
		String city = recruitJob.getCity();
		if (TextUtils.isEmpty(city)) {
			city = this.city;
		}

		tv_text.setText(recruitJob.getUsername());
		tv_data.setText(TimeFormatUtils.format(recruitJob.getTime()));

		tv_recruit_job.setText("[" + city + ">招聘]");

		tv_content.setText(recruitJob.getTitle());
		ImageUtils.circle(activity, recruitJob.getHeadphoto(), tv_image);

		return convertView;
	}
}
